//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for Macie
public struct MacieErrorType: AWSErrorType {
    enum Code: String {
        case accessDeniedException = "AccessDeniedException"
        case internalException = "InternalException"
        case invalidInputException = "InvalidInputException"
        case limitExceededException = "LimitExceededException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize Macie
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// You do not have required permissions to access the requested resource.
    public static var accessDeniedException: Self { .init(.accessDeniedException) }
    /// Internal server error.
    public static var internalException: Self { .init(.internalException) }
    /// The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
    public static var invalidInputException: Self { .init(.invalidInputException) }
    /// The request was rejected because it attempted to create resources beyond the current AWS account limits. The error code describes the limit exceeded.
    public static var limitExceededException: Self { .init(.limitExceededException) }
}

extension MacieErrorType: Equatable {
    public static func == (lhs: MacieErrorType, rhs: MacieErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension MacieErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
